import logging
from aiogram import executor
from constants.callback_events import SELECT_EXAM_ACTION, SELECT_SUBJECT_ACTION
from filters.callback_data_includes_filter import ActionTypeFilter
from bot import dispatcher
from handlers import select_exam_callback_handler, start_handler, cancel_handler, select_subject_callback_handler, check_answer_handler
from states.question import QuestionState

logging.basicConfig(level=logging.INFO)
dispatcher.register_message_handler(
    cancel_handler,
    commands=["cancel"],
    state="*",
)

dispatcher.register_message_handler(
    start_handler,
    commands=["start"],
)

dispatcher.register_message_handler(
    check_answer_handler,
    state=QuestionState.answer
)

dispatcher.register_callback_query_handler(
    select_exam_callback_handler,
    ActionTypeFilter(SELECT_EXAM_ACTION),
    state=QuestionState.exam_type,
)

dispatcher.register_callback_query_handler(
    select_subject_callback_handler,
    ActionTypeFilter(SELECT_SUBJECT_ACTION),
    state=QuestionState.subject,
)


if __name__ == "__main__":
    executor.start_polling(dispatcher)
